<template>
    <div class="components-container">
       
         <div class="layui-inline">
            <label class="layui-form-label" >查询日期</label>
            <el-date-picker v-date v-model="selectData.DateStart" type="date" placeholder="选择日期范围" @change="btnSearch">
            </el-date-picker>
             <el-date-picker v-date v-model="selectData.DateEnd" type="date" placeholder="选择日期范围" @change="btnSearch">
            </el-date-picker>
        </div>
        <el-button type="primary" @click="btnSearch" :loading="this.$store.state.isloading">搜索</el-button>
        <el-button  @click="btnRepeat" >重置</el-button>
        <div style="height:56px">
            <ul class="toolList">
                <li><el-button type="primary" @click="btnSearch" :loading="this.$store.state.isloading">刷新</el-button></li>
                <li v-if="btnShow(item.BTNVALUE)" v-for="(item, index) in $store.state.btnListCommon" @click="operate(item.BTNVALUE)">
                  <el-button type="primary" :value="item.BTNSHOWNAME" v-text="item.BTNSHOWNAME"></el-button>
                </li>
            </ul>
        </div>
        <dataTable :headList="headList" :dataList="dataList" :pageOrder="pageOrder" @pageChange="pageChange" @selectRow="selectRow"></dataTable>
      
       <printmodal ref="printPdf"></printmodal>
        <balanceManageMain ref="dialog" @refreshData="getData"></balanceManageMain>
    </div>
</template>

<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
.el-button + .el-button {
  margin-left: 0;
}
.btnCenter {
  text-align: center;
}
</style>
<script>
import sweetModal from "@/components/sweetModal";
import dataTable from "@/components/Table/DataTable";
import apiBase from "@/api/apiBase.js";
import balanceManageMain from "./balanceManageMain";
import balanceManageMainYW from "@/views/idv/330782X1F1/warehouse/balanceManageMain";
import { formatDate, timeStringToDate } from "@/utils/date.js";
import { manage } from "@/mixins/managePage.js";
import { DATESELECTMODE } from "@/const/const.js";
import { ORDER } from "@/const/orderConst.js";
import { PRINT } from "@/components/Pdf/PDF.js";
import printmodal from "@/components/Pdf/Print";
import informationRegistrationVue from '../jointPlatform/informationRegistration.vue';
const orgcode = typeof getOrgCode === "function" ? getOrgCode() : '';


const BALANCE = "结存";
const INFO = '详情';


export default {
  name: "arehousingManage",
  mixins: [manage],
  data() {
    return {
      DateSelectMode: DATESELECTMODE,
      //查询条件
      selectData: {
          DateStart: null,
          DateEnd: null
      },
      //收费信息
      chdData: {},
      //付款方式
      payment: [],
      CHDCODNAME: null,
      chlList: []
    };
  },
  methods: {

    //获取收费信息
    getData() {
      let selectData = JSON.parse(JSON.stringify(this.selectData));
      // if (!this.selectData.RegbussnumLike) {
      //   selectData.RegbussnumLike = null;
      // }
      selectData.DateStart = formatDate(
        selectData.DateStart,
        "yyyyMMdd"
      );
      selectData.DateEnd = formatDate(
        selectData.DateEnd,
        "yyyyMMdd"
      );
      let data = {
        PageIndex: this.pageOrder.currentPage,
        PageSize: this.pageOrder.pageSize,
        OrderBy: this.pageOrder.orderType,
        OrderByType: this.pageOrder.orderSort,
        Data: selectData
      };
      apiBase.DoService(data, apiBase.getApiAdress().Depot.QueryBalance, res => {
        this.dataList = res.data.content.OutData;
        this.pageOrder.totalNum = res.data.content.RecordCount;
        this.dataList.forEach(data => {
          data.REGDATE = data.REGDATE.substring(0, 16);
        });
      });
    },
    //获取表头
    getheaderlist(){
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Column.GetBalanceColumns,
        res => {
          this.headList = res.data.content;
        }
      )
    },
    //功能操作
    operate(order) {
      this.order = order;
      switch (this.order) {
        case BALANCE:
          this.$refs.dialog.open(this.order);
          break;
        case INFO:
          this.$refs.dialog.open(this.order,this.currentRow.BAEID);
        default:
      }
    },
   
    //查询条件重置
    btnRepeat() {
      this.selectData = {};
      this.getData();
      this.selectData.DateStart = new Date();
      this.selectData.DateStart.setDate(1);
      this.selectData.DateEnd = new Date();
    },
    dataRepeat() {
      this.chdData = {};
    },
    //按钮显隐
    btnShow(btn) {
      if(btn === BALANCE) return true;
     
    },
   
  },
  components: {
    sweetModal,
    dataTable,
    printmodal,
    balanceManageMain:(()=>{
      switch (orgcode) {
        case '330782X1F1':
          return balanceManageMainYW
          break;
        default:
          return balanceManageMain
          break;
      }
    })()
  },
  activated() {
    this.getData();
  },
  mounted() {
  },
  created() {
    this.getheaderlist();
    this.selectData.DateStart = new Date();
    this.selectData.DateStart.setDate(1);
    this.selectData.DateEnd = new Date();
  },
  watch: {
   
  }
};
</script>

